package com.cskaoyan.controller;

import com.cskaoyan.bean.*;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.vo.DashBoardDataVo;
import com.cskaoyan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description:窄化请求，找到对应的方法
 * @author: landz
 * @create: 2022-12-29 11:45
 * @version:
 */
@RestController
@RequestMapping("admin")
public class UserController {

    @Resource
    UserService userService;


    //page=1&limit=20&username=ppp123&mobile=18152747836&sort=add_time&order=desc
    @RequestMapping("user/list")
    public BaseRespVo list(BasePageInfo info, String username, String mobile) {
        CommonData<MarketUser> data = userService.list(info, username, mobile);
        return BaseRespVo.ok(data);
    }

    /**
     * id=22
     *
     * @param * @param null
     * @return {@link null}
     * @Description: 用户管理模块会员管理中根据用户id查询
     * @version v1.0
     * @author landz
     * @date 2022/12/31 11:21
     */
    @RequestMapping("user/detail")
    public BaseRespVo userDetail(@RequestParam("id") Integer id) {
        MarketUser marketUser = userService.userDetail(id);
        return BaseRespVo.ok(marketUser);
    }


    /**
     * @return com.cskaoyan.bean.common.BaseRespVo
     * @author landz
     * @create 2022/12/31 15:35
     * 用户管理模块中会员管理功能中详情修改数据update接口实现
     **/
    @PostMapping("user/update")
    public BaseRespVo userUpdate(@RequestBody MarketUser marketUser) {
        userService.userUpdate(marketUser);
        return BaseRespVo.ok();
    }


    @RequestMapping("dashboard")
    public BaseRespVo dashboard() {
        DashBoardDataVo dashBoardDataVo = userService.dashboard();
        return BaseRespVo.ok(dashBoardDataVo);
    }

    //page=1&limit=20&sort=add_time&order=desc
    //page=1&limit=20&name=1&userId=&sort=add_time&order=desc
    @RequestMapping("address/list")
    public BaseRespVo addressList(BasePageInfo info) {
        CommonData<MarketAddress> data = userService.addressList(info);
        return BaseRespVo.ok(data);
    }

    //page=1&limit=20&userId=11&valueId=1181019&sort=add_time&order=desc
    @RequestMapping("collect/list")
    public BaseRespVo collectList(BasePageInfo info) {
        //会员收藏功能实现
        CommonData<MarketCollect> data = userService.collectList(info);
        return BaseRespVo.ok(data);
    }

    //page=1&limit=20&userId=1&goodsId=1181013&sort=add_time&order=desc
    @RequestMapping("footprint/list")
    public BaseRespVo footprintList(BasePageInfo info) {
        CommonData<MarketFootprint> data = userService.footPrintList(info);
        return BaseRespVo.ok(data);
    }

    //page=1&limit=20&userId=1&keyword=%E6%AF%8D&sort=add_time&order=desc
    @RequestMapping("history/list")
    public BaseRespVo historyList(BasePageInfo info) {
        CommonData<MarketSearchHistory> data = userService.historyList(info);
        return BaseRespVo.ok(data);
    }

    //page=1&limit=20&username=user123&sort=add_time&order=desc&id=33
    @RequestMapping("feedback/list")
    public BaseRespVo feedbackList(BasePageInfo info) {
        CommonData<MarketFeedback> data = userService.feedBackList(info);
        return BaseRespVo.ok(data);
    }

}
